<html lang="en">

<head>
    <title>Todost ✍️</title>
    <meta name="viewport" content="height=device-height, initial-scale=1, user-scalable=no">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../component/layui/css/layui.css">
    <link rel="stylesheet" href="../../css/homde_index.css">
    <script src="../../js/myUtils.js"></script>
</head>


<body class="body">
    <div class="task-manager">
        <div class="right-bar">
            <div class="header">📙 未及时反馈，需优先处理</div>
            <div class="right-content" id='urgent'></div>

        </div>
    </div>


    <script src="../../component/layui/layui.js"></script>
    <script src="../../component/pear/pear.js"></script>
    <script id="urgentView" type="text/html">
        {{# layui.each(d.list, function(index, item){ }}
        {{#  if(index%4 === 0){ }}
        <div class="task-box red">
        {{#  } else if(index%4 === 1) { }}
        <div class="task-box blue">
        {{#  } else if(index%4 === 2) { }}
        <div class="task-box yellow">
        {{#  } else if(index%4 === 3) { }}
        <div class="task-box green">
        {{#  } }}
            <div class="description-task">
                <div class="time">{{item.no}}</div>
                <div class="task-name">截止时间：</div>
            </div>
            <div class="more-button"></div>
            <div class="members">
                <div class="task-name">{{item.feedbackTime}}</div>
            </div>
        </div>
        {{# }); }}
    </script>

    <script>
        layui.use(['jquery', 'Api', 'laytpl', 'layer', 'request'], function () {
            var $ = layui.jquery,
                Api = layui.Api,
                request = layui.request,
                laytpl = layui.laytpl;

            getUrgent()

            function getUrgent() {
                var params = {
                    page_index: 1,
                    page_size: 100
                }
                var success = function (res) {
                    if (res.errno == 0) {
                        var data = res.data
                        var dataList = data.list
                        for (var i = 0; i < dataList.length; i++) {
                            var sendTime = dataList[i].sendTime
                            var feedbackTimeLimit = dataList[i].feedbackTimeLimit
                            var feedbackTimeReal = dataList[i].feedbackTime
                            if(feedbackTimeReal == null || feedbackTimeReal == ''){
                                var feedbackTime = myUtils.dayAdd(sendTime, parseInt(feedbackTimeLimit))
                            }else{
                                var feedbackTime = myUtils.dayAdd(feedbackTimeReal, parseInt(feedbackTimeLimit))
                            } 
                            dataList[i].feedbackTime = feedbackTime
                        }
                        data.list = dataList
                        // console.log("getUrgent data:", data)
                        var getTpl = urgentView.innerHTML,
                            view = document.getElementById('urgent');
                        laytpl(getTpl).render(data, function (html) {
                            view.innerHTML = html;
                        });
                    } else {
                        layer.msg(res.errmsg, {
                            icon: 2
                        })
                    }
                }
                request.get(Api.homeUrgent, params, success)
            }
        });

        function getNo(noStr) {
            // console.log("noStr", noStr)
            window.clipboardData.setData("Text", noStr);
        }
    </script>
</body>


</html>